package com.bookstore.dao.impl;

import com.bookstore.dao.BaseDao;
import com.bookstore.dao.OrderItemDao;
import com.bookstore.entity.OrderItem;
import com.bookstore.entity.User;

import java.util.List;

public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {
    @Override
    public int insertOrderItem(OrderItem orderItem) {
        String sql="insert into t_order_item(order_id,product_id,buynum) values(?,?,?)";
        return super.update(sql,orderItem.getOrder_id(),orderItem.getProduct_id(),orderItem.getBuynum());
    }

    @Override
    public int updateOrderItem(OrderItem orderItem) {
        String sql="update t_order_item order_id=?,product_id=?,buynum=? where order_item_id=?";
        return super.update(sql,orderItem.getOrder_id(),orderItem.getProduct_id(),orderItem.getBuynum(),orderItem.getOrder_item_id());
    }

    @Override
    public int deleteOrderItem(Long orderItemId) {
        String sql="delete from t_order_item where order_item_id=?";
        return super.update(sql,orderItemId);
    }

    @Override
    public List<OrderItem> queryAllOrderItem() {
        String sql="select * from t_order_item";
        return super.queryMore(OrderItem.class,sql);
    }

    @Override
    public OrderItem queryOrderItemId(Long orderItemId) {
        String sql="select * from t_order_item where order_item_id=?";
        return super.queryOne(OrderItem.class,sql,orderItemId);
    }
}
